package com.lunhui.user.provider.config;

import net.bull.javamelody.MonitoringFilter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.HashMap;
import java.util.Map;

/**
 * @author renminghe-kg
 */
@Configuration
public class AppConfig {

    @Bean(name = "monitoringFilter")
    public org.springframework.boot.web.servlet.FilterRegistrationBean filterMonitoringFilter() {
        org.springframework.boot.web.servlet.FilterRegistrationBean filterRegistrationBean = new org.springframework.boot.web.servlet.FilterRegistrationBean();
        filterRegistrationBean.setFilter(new MonitoringFilter());
        filterRegistrationBean.setEnabled(true);
        filterRegistrationBean.addUrlPatterns("/*");
        Map<String, String> initParameters = new HashMap<>();
        initParameters.put("contextConfigLocation", "classpath:net/bull/javamelody/monitoring-spring.xml");
        filterRegistrationBean.setInitParameters(initParameters);
        return filterRegistrationBean;
    }
}